package com.mia.craftstudio.minecraft;

import net.minecraft.util.EnumFacing;

public class ImmutableDirectionHolder {
   private final int[] offset;
   private final EnumFacing[] directions;

   public ImmutableDirectionHolder(EnumFacing... facings) {
      this.directions = facings;
      this.offset = this.getOffsets();
   }

   private int[] getOffsets() {
      int[] offsets = new int[3];
      EnumFacing[] var2 = this.directions;
      int var3 = var2.length;

      for(int var4 = 0; var4 < var3; ++var4) {
         EnumFacing fd = var2[var4];
         if (fd != null) {
            offsets[0] += fd.getFrontOffsetX();
            offsets[1] += fd.getFrontOffsetY();
            offsets[2] += fd.getFrontOffsetZ();
         }
      }

      return offsets;
   }

   public int[] getOffset() {
      return this.offset;
   }

   public EnumFacing[] getDirections() {
      return this.directions;
   }

   public String toString() {
      String s = "ImmutableDirectionHolder : ";
      EnumFacing[] var2 = this.directions;
      int var3 = var2.length;

      int var4;
      for(var4 = 0; var4 < var3; ++var4) {
         EnumFacing direction = var2[var4];
         s = s + direction;
         s = s + " ";
      }

      s = s + " | ";
      int[] var6 = this.offset;
      var3 = var6.length;

      for(var4 = 0; var4 < var3; ++var4) {
         float v = (float)var6[var4];
         s = s + v;
         s = s + " ";
      }

      return s;
   }

   public boolean equals(Object obj) {
      if (!(obj instanceof ImmutableDirectionHolder)) {
         return false;
      } else {
         ImmutableDirectionHolder o = (ImmutableDirectionHolder)obj;
         if (this.directions.length != o.directions.length) {
            return false;
         } else {
            return this.offset[0] == o.offset[0] && this.offset[1] == o.offset[1] && this.offset[2] == o.offset[2];
         }
      }
   }

   public int hashCode() {
      return 1048576 * this.offset[0] + 1024 * this.offset[1] + this.offset[2];
   }
}
